package bank;

public class _58LengthOfLastWord {
    public static int lengthOfLastWord(String s) {
        s = s.trim();
        if (s.length() == 0){
            return 0;
        }
        int res = 0;
        for (int i = s.length()-1;i >= 0;i--){
            if (s.charAt(i) != ' '){
                res ++;
            }else {
                break;
            }
        }
        return res;
    }
}
